<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>PCMS内容管理系统</title>
<link href="<?php echo $_tpl['css']; ?>admin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<?php echo $_tpl['js']; ?>jquery.js"></script>
<script language="javascript">
function check()
{
	var item = document.getElementById( "cate_id" );

	if ( item.options[item.selectedIndex].value == -1 )
	{
		alert( "请选择栏目" );
		item.focus();
		return false;
	}

	var item = document.getElementById( "type" );

	if ( item.options[item.selectedIndex].value == 0 )
	{
		alert( "请选择类型" );
		item.focus();
		return false;
	}

	var up_tpl_way = document.getElementById( 'up_tpl_way' );

	if ( up_tpl_way == 1 )
	{
		var item = document.getElementById( "htmlfile" );

		if ( item.value == "" )
		{
			alert( "请选择文件" );
			item.focus();
			return false;
		}
	}

	if ( up_tpl_way == 2 )
	{
		var item = document.getElementById( "src_cate_id" );

		if ( item.value == "" )
		{
			alert( "请选择模板来源栏目" );
			item.focus();
			return false;
		}
	}

	document.getElementById( "submit" ).disabled = true;
	return true;
}

function change_up_tpl_way( id )
{
	var up_tpl_tr1 = document.getElementById( 'up_tpl_tr1' );
	var up_tpl_tr2 = document.getElementById( 'up_tpl_tr2' );

	if ( id == 1 )	//本地上传
	{
		$('#up_tpl_tr1').show();
		$('#up_tpl_tr2').hide();
		//up_tpl_tr1.style.display = 'block';
		//up_tpl_tr2.style.display = 'none';
	}

	if ( id == 2 )	//引用
	{
		$('#up_tpl_tr1').hide();
		$('#up_tpl_tr2').show();
		//up_tpl_tr1.style.display = 'none';
		//up_tpl_tr2.style.display = 'block';
	}
}
</script>
</head>
<body>
<form id="apply" method="post" enctype="multipart/form-data" onsubmit="return check()">
<input type="hidden" name="reference" value="<?php echo $reference; ?>">
<center><h3>添加模板文件</h3></center>
<table width="90%" border="0" align="center" cellpadding="5" cellspacing="1">
  <tr>
    <td width="38%" height="20" align="right" bgcolor="#272727">栏目</td>
    <td width="62%" height="20"  align="left" bgcolor="#272727"><select id="cate_id" name="cate_id"><option value="-1">请选择</option><option value="0">整站通用模板</option><?php
	if ( isset( $cate_data ) && is_array( $cate_data ) )
	{
		foreach ( $cate_data as $index => $value )
		{
			echo '<option value="' . $value['id'] . '">' . str_repeat( '&nbsp;&nbsp;', $value['level'] ) . $value['cname'] . '</option>';
		}
	}
	?></select></td>
  </tr>

  <tr>
    <td width="38%" height="20" align="right" bgcolor="#272727">类型</td>
    <td width="62%" height="20" align="left" bgcolor="#272727"><select id="type" name="type"><option value="0">请选择</option><?php
	if ( isset( $tpl_type_cname ) && is_array( $tpl_type_cname ) )
	{
		foreach ( $tpl_type_cname as $index => $value )
		{
			if ( $index == 0 )
			{
				continue;
			}
			echo '<option value="' . $index . '">' . $value . '</option>';
		}
	}
	?></select></td>
  </tr>

  <tr>
    <td width="38%" height="20" align="right" bgcolor="#272727">模板来源</td>
    <td width="62%" height="20" align="left" bgcolor="#272727"><input type="radio" name="up_tpl_way" id="up_tpl_way" value="1" checked	 onclick="change_up_tpl_way(1)" />  本地上传 <input type="radio" name="up_tpl_way" id="up_tpl_way" value="2" onclick="change_up_tpl_way(2)"/> 引用其它栏目模板</td>
  </tr>

  <tr id="up_tpl_tr1">
    <td width="38%" height="20" align="right" bgcolor="#272727">文件</td>
    <td width="62%" height="20" align="left" bgcolor="#272727"><input type="file" name="htmlfile" id="htmlfile" /> *仅支持htm,html格式</td>
  </tr>

  <tr id="up_tpl_tr2" style="display:none">
    <td width="38%" height="20" align="right" bgcolor="#272727">模板来源栏目</td>
    <td width="62%" height="20" align="left" bgcolor="#272727"><select id="src_cate_id" name="src_cate_id"><option value="-1">请选择</option><?php
	if ( isset( $cate_data ) && is_array( $cate_data ) )
	{
		foreach ( $cate_data as $index => $value )
		{
			echo '<option value="' . $value['id'] . '">' . str_repeat( '&nbsp;&nbsp;', $value['level'] ) . $value['cname'] . '</option>';
		}
	}
	?></select></td>
  </tr>

  <tr>
    <td height="20" colspan="2" align="center" bgcolor="#000000">
		<table width="40%">
			<tr align="center">
				<td><input class="btn2" type="submit" id="submit" value="提交"></td>
				<td><input class="btn2" type="button" value="返回" onclick="window.location.href='<?php echo $reference; ?>'"></td>
			</tr>
		</table>
	</td>
  </tr>
</table>
</form>

</body>
</html>